<?php

namespace app\admin\controller\routine;

use Throwable;
use app\common\controller\Backend;
use app\admin\model\Sms as SmsModel;

class Sms extends Backend
{
    /**
     * 模型
     * @var object
     * @phpstan-var SmsModel
     */
    protected object $model;

    protected array|string $preExcludeFields = ['phone'];

    protected array|string $quickSearchField = ['phone'];

    /**
     * 开启数据限制
     */
    protected string|int|bool $dataLimit = 'allAuthAndOthers';

    protected string $dataLimitField = 'id';

    public function initialize(): void
    {
        parent::initialize();
        $this->model = new SmsModel();
    }

    /**
     * 查看
     * @throws Throwable
     */
    public function index(): void
    {
        if ($this->request->param('select')) {
            $this->select();
        }

        list($where, $alias, $limit, $order) = $this->queryBuilder();
        $res = $this->model
            ->alias($alias)
            ->where($where)
            ->order($order)
            ->paginate($limit);

        $this->success('', [
            'list'   => $res->items(),
            'total'  => $res->total(),
            'remark' => get_route_remark(),
        ]);
    }
}